package com.bw.z;

import android.app.Application;

import com.bw.z.db.DBManager;
import com.bw.z.db.DaoSession;

public class App extends Application {

    private static App instance;
    public static DaoSession session;
    public static DBManager dbManager;

    public static App getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        initDB();
    }

    private void initDB() {

        // 1、获取需要连接的数据库
        // 2、创建数据库连接
        dbManager = new DBManager(this);
        // 3、创建数据库会话
        session = dbManager.getDaoSession();
    }

    // 供外接使用
    public DaoSession getDaoSession() {
        return session;
    }
}
